<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>服务残疾人统计</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('AdminLaoren/statistics')}" id="search">
        <input type="hidden" name="pagenum" value="{$pagenum|default='10'}" id="pagenum">
        年份:
        <input type="number" min="2022" max="{$maxYear}" step="1" value="{$year}" class="form-control" name="year" style="width: 120px;" value="{$year|default=''}"
               placeholder="请输入年份">
        服务类型:
        <select class="form-control" name="serviceType">
            <option value="已服务"  <if condition="$serviceType eq '已服务'">selected</if>>已服务</option>
            <option value="未服务"  <if condition="$serviceType eq '未服务'">selected</if>>未服务</option>
        </select>
        残疾等级:
        <select class="form-control" name="olderType">
            <option value=""  >全部</option>
            <option value="一级"  <if condition="$olderType eq '一级'">selected</if>>一级</option>
            <option value="二级"  <if condition="$olderType eq '二级'">selected</if>>二级</option>
            <option value="三级"  <if condition="$olderType eq '三级'">selected</if>>三级</option>
            <option value="四级"  <if condition="$olderType eq '四级'">selected</if>>四级</option>
        </select>
        地区:
        <input class="form-control" type="text" style="width:300px;" required value="" placeholder="请选择社区"
               onclick="doSelectCategory();" id="js-categories-name-input" readonly />
        <input class="form-control" type="hidden" value="" name="category" id="js-categories-id-input" />
        <button class="btn btn-primary">搜索</button>
    </form>
    <form class="js-ajax-form" method="post">
        <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" onclick="daochu1()"
                data-subcheck="true" data-msg="确定导出数据吗？">导出
        </button>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="80">序号</th>
                <th width="80">姓名</th>
                <th width="100">残疾等级</th>
                <th width="80">性别</th>
                <th width="80">年龄</th>
                <th width="100">身份证</th>
                <th width="100">联系电话</th>
                <th width="120">街道社区</th>
                <th width="160">医疗机构</th>
                <th width="160">理发机构</th>
                <th width="160">保洁公司</th>
                <th width="160">服务总次数</th>
                <th width="80">消费金额</th>
                <th width="80">余额</th>
            </tr>
            </thead>
            <foreach name="pages" key="key" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id_card}" data-id="{$vo.id_card}">
                    </td>
                    <td>{$xhpage + $key}</td>
                    <td>{$nameArray[$key]}</td>
                    <td>{$olderTypeArray[$key]}</td>
                    <td>{$sexArray[$key]}</td>
                    <td>{$ageArray[$key]}</td>
                    <td>{$vo.id_card}</td>
                    <td>{$telArray[$key]}</td>
                    <td>{$communityArray[$key]}</td>
                    <td>{$medicalInstitutionCountArray[$key]}</td>
                    <td>{$hairSalonCountArray[$key]}</td>
                    <td>{$cleaningCompanyCountArray[$key]}</td>
                    <td>{$serviceTotalCountArray[$key]}</td>
                    <td>{$consumptionAmountArray[$key]}</td>
                    <td>{$balanceArray[$key]}</td>
                </tr>
            </foreach>
        </table>

        <div class="table-actions">
            每页条数： <select style="width: 100px; " name="pagenum" onchange="changePage(this);">
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="50">50</option>
            <option value="100">100</option>
            <option value="200">200</option>
            <option value="500">500</option>
            <option value="1000">1000</option>
        </select><br>
            <div class="pagination">{$page}</div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js?1"></script>
<script>
    $('select[name=pagenum]').val("{$pagenum|default='10'}");

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/sqselect')}?ids=3,4,5,6,7,8,9,10,11&yxid=" + selectedCategoriesId, '请选择社区', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择社区');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }

    function changePage(num){
        $('#pagenum').val(num.value);
        var params=getFormParam();
        window.location.href='?'+params;
    }

    function daochu1() {
        var bookVersionId = '0';
        $.each($('input[type=checkbox]:checked'), function (i, itesm) {
            var examResultIds = $(itesm).attr('data-id');
            bookVersionId = bookVersionId +  ',' + examResultIds;
        });
        console.log(bookVersionId);
        var params=getFormParam();
        window.location.href = 'statisticsDaochu.html?dcid=' + bookVersionId + "&" + params;
    }

    function getFormParam(){
        var params = $('#search').serialize();
        return params;
    }
</script>
</body>
</html>